Skip to content

fix(fleet-proxy): re-resolve the tailnet egress at tunnel-open time - #13080

Merged
dezren39 merged 1 commit into
mainfrom
lane-lj-12426
Nov 23, 2026
Merged

dezren39 merged 1 commit into
mainfrom
lane-lj-12426

Conversation

@dezren39

@dezren39 dezren39 commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Fixes #12426.

What was still broken

PR #12645 (for #12555) made tailnet tunnel construction prefer the seat's recorded tailnet proxy (fleet-proxy.env) over the ambient HTTPS_PROXY. But fleet proxy serve resolved that egress once at startup and cached it in the Broker for the process's whole life. A broker auto-spawned while tailscaled was down — or before bootstrap wrote fleet-proxy.env — was born with the ambient egress value (or none) and kept it forever: queue/shell tailnet tunnels stayed broken after the tailnet recovered until someone restarted the broker by hand. That is exactly the outage shape #12555 recorded and the restart path #12426's seat fix had to do manually.

The change (one file: pkgs/fleet/crates/fleet-proxy/src/serve.rs)

  • Both tailnet tunnel opens (open_raw_tunnel, and the tailnet branch of open_conn_raw) now call a new Broker::tailnet_egress(), which resolves fresh via the existing egress_from_env (recorded tailnet proxy first, ambient env second) on every open.
  • The preference is a small pure function, resolve_tailnet_egress: fresh resolution wins; the startup parse is the fallback when fresh resolution fails; with neither, the resolution error (the same message the startup warning prints) surfaces.
  • The startup parse stays: it still drives the startup warning line, and is now documented as the fallback.
  • Cost: opens are pooled and recovery-gated, so this is one small file read per new tunnel, not per request.
  • Out of scope, deliberately: the Cloudflare leg's egress (egress_from_env_url_port) still uses the ambient env, cached at startup — the platform egress proxy is that leg's correct source, and it is not part of the fleet proxy serve inherits the sandbox egress HTTPS_PROXY in userspace mode; queue/shell legs fail until it is restarted with tailscaled's CONNECT proxy #12426 failure mode. The spawn sites (bootstrap hint, spawn_serve env inheritance) no longer matter for tailnet routing once the value is read at open time, so they are untouched.

Verification

  • New unit tests naming the oracle — tailnet_egress_fresh_resolution_wins_over_the_startup_parse, tailnet_egress_falls_back_to_the_startup_parse, tailnet_egress_without_either_surfaces_the_resolution_error — all pass.
  • cargo test -p fleet-proxy: 113 passed / 0 failed (plus 14 in the crate's other test target), run on the laptop at the PR head's parent state; cargo fmt -p fleet-proxy clean.
  • With this merged, a broker's inherited environment no longer steers its tailnet tunnels at any point in its life, which also retires the premise of the external /proc-environ watchdog described on fleet proxy serve: auto-spawned broker inherits the caller ambient proxy env and silently breaks tailnet tunnels #12555.

Run Proof
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d46c7850-f9f3-4918-914f-429ad1561d97
Commits

Reviewing files that changed from the base of the PR and between f2a50a9 and bc8b3a9.

Files selected for processing: 1

  • pkgs/fleet/crates/fleet-proxy/src/serve.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T08:00:52.576863Z 282fedb PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

The broker parsed its tailnet egress once at startup. A broker
auto-spawned while tailscaled was down (or before bootstrap wrote
fleet-proxy.env) kept the ambient egress value — or none — for
its whole life, so queue/shell tailnet tunnels kept failing
after the tailnet recovered until a manual restart. That is the
startup-cache half of the #12426 failure mode, left after the
read-time preference landed for #12555 in #12645.

Tunnel opens now resolve fresh via egress_from_env (recorded
tailnet proxy first, ambient env second), falling back to the
startup parse when fresh resolution fails. Opens are pooled
and recovery-gated, so the re-read costs one small file read
per new tunnel, not per request. The Cloudflare leg's egress
is unchanged: the ambient platform proxy is its correct source.

Oracle: the resolve_tailnet_egress preference — a fresh
resolution wins, the startup parse is the fallback, and with
neither the resolution error surfaces. Three unit tests cover
the three branches; the fleet-proxy suite passes 113/113.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fleet proxy serve inherits the sandbox egress HTTPS_PROXY in userspace mode; queue/shell legs fail until it is restarted with tailscaled's CONNECT proxy

1 participant